package meihua.stopcarapp.ui.fragment;

import java.util.HashMap;

import meihua.mylibrary.base.BaseFragment;

/**
 * Name: LGZ
 * Time: 2017/5/18.
 * Dec:
 */

public class FragmentFactory {

    public static final int TAB_INDENT_SPEND = 0;   //消费明细
    public static final int TAB_INDENT_UEARNINGS = 1;//共享明细
    public static final int TAB_INDENT_URECHANGE = 2;//充值明细

    private static HashMap<Integer, BaseFragment> mFragments = new HashMap<>();
    private static BaseFragment fragment;

    public static BaseFragment createFragment(int position) {
        // 获取到内存里面是否有fragment
        fragment = mFragments.get(position);
        // 说明内存没有
        if (null == fragment) {
            switch (position) {

                case TAB_INDENT_SPEND:
                    fragment = new SpendFragment();
                    break;
                case TAB_INDENT_UEARNINGS:
                    fragment = new UearningsFragment();
                    break;
                case TAB_INDENT_URECHANGE:
                    fragment = new UrechangeFragment();
                    break;
            }
            //添加到内存
            mFragments.put(position, fragment);

        }

        return fragment;
    }

}
